<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}
</style>
</head>
<body class="gray-bg">

	<!-- 隐藏域 -->
	<input type="hidden" value="${busiId}" id="busiId" name="busiId" />
	<!-- 隐藏域 -->

	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;财务相关>确认结清单</span>
		</div>
		<div class="buttonfixed">
			<button type="button" class="btn dpbtn_blue btnaplly"
				onclick="save();">确认结清单</button>
		</div>
		<div class="ibox-content ibox-con">
			<%@include file="/jsp/common_yw_with_loan_include.jsp"%>
			<div class="business-manwife">结清信息</div>
			<div class="business-padding">
				<form class="form-horizontal" id="commentForm">
					<table cellpadding="0" cellspacing="0" border="0"
						class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">结清类型：</label>
							</td>
							<td class="td-width"><select class="select-control"
								id="type_settle" name="type_settle"> &nbsp;
							</select></td>
						</tr>
						<tr style="display: none;">
							<td align="right"><label class="control-label np">违约金：</label></td>
							<td>
								<input id="amount_penalty" name="amount_penalty" min="0"
								maxlength="20" type="number" class="form-control" value="0"
								aria-required="true" placeholder="违约金" readonly="readonly"/>
							</td>
						</tr>
						<tr>
							<td align="right"><label class="control-label np">收到时间：</label></td>
							<td>
								<input id="time_receive" name="time_receive"
								minlength="1" maxlength="20" type="text"
								class="laydate-icon form-control" onclick="laydate()"
								required="" aria-required="true" placeholder="收到时间(必填)"/>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="business-manwife">经办信息</div>
			<div class="padding-nono">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">经办人：</label>
						</td>
						<td><input class="form-control" type="text" id="" name=""
							readonly="readonly" value="${current_user_key.uname}" /></td>
						<td align="right"><label class="control-label np">经办时间：</label>
						</td>
						<td><input id="jb_time" name="jb_time" placeholder="经办时间"
							class="laydate-icon form-control" 
							placeholder="经办时间(必填)" readonly="readonly"/></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script type="text/javascript"
		src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript" src="${basePath}/js/commonvalidate.js"
		charset="utf-8"></script>
	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    $(function(){
	    	$("#commentForm").validate({
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        }); 
	    });

	     $(function(){
	    	
	    	 initData();
	    	 
	    	 var date = new Date();
		     document.getElementById("jb_time").value = date.format("yyyy-MM-dd h:m:s");
	     });
	     
	     var initData = function()
	     {
	    	 var busiId = $('#busiId').val();
	    	 $.dpAjax({
	    		show:false,
	 	   		url:'${basePath}/CaiWuXiangGuanController/getDataDictionaryList',
	 	   		data:{"busiId":busiId},
	 			success: function(datas){
	 		 	  if(datas.flag == "100100")
	 		 	  {
	 		 		  var d = datas.caiwujieqing_result;
	 		 		  if(d && null != d)
	 		 		  {
	 		 			  var objs = '';
		 		 		  for(var key in d)
		 		 		  {
		 		 			  objs += '<option value="'+key+'">'+d[key]+'</option>';
		 		 		  } 
		 		 		  $('#type_settle').html(objs);
	 		 		  }
	 		 		  
	 		 		  var d = datas.dhSettle;
	 		 		  if(d && null != d)
	 		 		  {
	 		 			  var t = document.getElementById("type_settle");  
		 		 		  for(i=0;i<t.length;i++)
		 		 		  {
		 		 			  if(t[i].value == d.typeSettle)
		 		 			  {
		 		 				  t[i].selected = true;
		 		 				  break;
		 		 			  }
		 		 		  }
		 		 		  $('#amount_penalty').val(d.amountPenalty);
		 		 		  $('#time_receive').val(d.timeReceive);
		 		 		  $('#amount_penalty').val(d.amountPenalty);
	 		 		  }
	 				  return;
	 			  }
	 			  if(datas.flag == "100200"){
	 				  alert(JSON.stringify(datas));
	 	              return;
	 	          }
	 			  layer.msg(datas.message, {icon: 2});
	 			}
	 	   	});
	     }
	     
	     
	     //保存
	     var save = function()
	     {
	    	 var validstatus = $("#commentForm").valid();
	    	 if(validstatus)
	    	 {
	    		 var busiId = $('#busiId').val();
		    	 var type_settle = $('#type_settle').val();
		    	 var amount_penalty = $('#amount_penalty').val();
		    	 var time_receive = $('#time_receive').val();
		    	 
		    	 var jb_time = $('#jb_time').val();
		    	 layer.confirm('确定执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
		  			  btn: ['确定','取消'],//按钮
			    	  title: '消息',
		  			},function(){
		  			 layer.closeAll();
			    	 $.dpAjax({
			 	   		url:'${basePath}/CaiWuXiangGuanController/caiWuXiangGuanKeHuJieQing',
			 	   		data:{
			 	   			"busiId":busiId,
			 	   			"cusId":"${current_user_key.id}",
			 	   			"typeSettle":type_settle,
			 	   			"amountPenalty":amount_penalty,
			 	   			"timeReceive":time_receive,
			 	   			"auditor":"${current_user_key.id}",
			 	   			"nameAuditor":"${current_user_key.name}",
			 	   			"timeAudit":jb_time,
				 	   		"id":busiId,
			 	   			"busiStatus":"9999"
			 	   		},
			 			success: function(datas)
			 			{
			 		 	  if(datas.flag == "100100"){
			 		 		  layer.msg("确认结清单执行成功！", {icon: 6});
			 		 		  setTimeout(function () {
			 		 			window.location.href = "${basePath}/web/daiHouYw/customerjieqingList.jsp";
			 		 		  }, 3000);

			 				  return;
			 			  }
			 			  if(datas.flag == "100200"){
			 				  alert(JSON.stringify(datas));
			 	              return;
			 	          }
			 			  layer.msg(datas.message, {icon: 2});
			 			}
			 	   	});
		  		},function(){
		  			layer.msg("已取消本次操作！", {icon: 6});
		  		});
	    	 }
	     }
    </script>
</body>
</html>
